/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Flavio
 */
public class DaoHelper {

    public Connection getConnection() throws SQLException  {
        Connection conn = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DaoHelper.class.getName()).log(Level.SEVERE, null, ex);
        }
        conn = DriverManager.getConnection("jdbc:mysql://localhost/debitosconta", "root", "");
        return conn;
    }
    private void closeFinnaly(Connection conn){
        if(conn ==null){
            return;
        }
        else{
            try {
                conn.close();
            } catch (SQLException ex) {
                Logger.getLogger(DaoHelper.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
     private void closeFinnaly(Statement stmt){
        if(stmt ==null){
            return;
        }
        else{
            try {
                stmt.close();
            } catch (SQLException ex) {
                Logger.getLogger(DaoHelper.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
      public void closeFinnaly (Statement stmt,Connection conn){
           closeFinnaly(conn);
            closeFinnaly(stmt);
     }
}
